package com.he.DesignPatterns.iterator;

import java.util.List;

/**
 * @description: 具体迭代器角色类
 * @Author: HCL
 * @Date: 2024/9/4 11:24
 */
public class StudentIteratorImpl implements StudentIterator {

    private List<Student> studentList;
    private int position = 0;

    public StudentIteratorImpl(List<Student> studentList) {
        this.studentList = studentList;
    }

    @Override
    public Boolean hashNext() {
        return studentList.size() > position;
    }

    @Override
    public Student next() {
        Student student = studentList.get(position);
        position++;
        return student;
    }
}
